package org.example.hrpc.registry.zookeeper;

import org.apache.curator.x.discovery.ServiceInstance;
import org.example.hrpc.common.spi.loader.ExtensionLoader;
import org.example.hrpc.loadbalance.LoadBalance;
import org.example.hrpc.loadbalance.RandomLoadBalance;
import org.example.hrpc.registry.ServiceMeta;

import java.util.List;

public class LoadBalanceUtils {
    public static ServiceInstance<ServiceMeta> selector(final List<ServiceInstance<ServiceMeta>> services, final String type) {
//        LoadBalance<ServiceInstance<ServiceMeta>> loadBalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(type);
        LoadBalance<ServiceInstance<ServiceMeta>> loadBalance = RandomLoadBalance.INSTANCE;
        return loadBalance.select(services);
    }
}
